Skip to content

Detach pins in HardwareSerial::setPins() #8619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from

Conversation

SuGlider
Copy link
Collaborator

@SuGlider SuGlider commented Sep 8, 2023

Description of Change

There is a bug in HardwareSerial::setPins() that sets the UART pins internally to the wrong value at the end of the operation, which may lead to errors in HardwareSerial::end(), not dettaching the right GPIO from UART.

This PR also makes sure that sequential HardwareSerial::setPins() will always detach previous attached GPIOs.

Tests scenarios

// Check previous GPIOs with a Logic Analyzer
void setup() {
  Serial.begin(115200);  // sets default RX and TX
  Serial.println("This will go out in the default TX pin");
  Serial.flush();
  
  Serial.setPins(-1, 2);  // Now TX shall be GPIO2 and default TX GPIO can't send any data
  Serial.println("This line can't be seen in the default TX GPIO!");
  Serial.flush();
}

void loop(){
}

Related links

Closes #8607

@SuGlider SuGlider self-assigned this Sep 8, 2023
@SuGlider
Copy link
Collaborator Author

SuGlider commented Sep 8, 2023

@me-no-dev - I had to create a new PR in order to rebase it to master branch.

@SuGlider SuGlider marked this pull request as draft September 10, 2023 14:17
@me-no-dev me-no-dev modified the milestones: 3.0.0, 2.0.13 Sep 12, 2023
@SuGlider
Copy link
Collaborator Author

@me-no-dev - This PR will remain as draft. Please review and merge #8629 to 2.0.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

HardwareSerial::setPins does not unset previous pin
2 participants